/*
 *  pixelformat.h
 *  libCV
 *
 *  Created by Gregory Koch on 16/01/11.
 *  Copyright 2011 IFlyBotIV. All rights reserved.
 *
 */

#ifndef CCVT_H
#define CCVT_H

#define MIN3(x,y,z)  ((y) <= (z) ? \
((x) <= (y) ? (x) : (y)) \
: \
((x) <= (z) ? (x) : (z)))

#define MAX3(x,y,z)  ((y) >= (z) ? \
((x) >= (y) ? (x) : (y)) \
: \
((x) >= (z) ? (x) : (z)))

#define SAT(c) \
if (c & (~255)) { if (c < 0) c = 0; else c = 255; }

#define CLIMIT(x)  ( (x) > 0xffff ? 0xff : ( (x) <= 0xff ? 0 : ( (x) >> 8 ) ) )


typedef struct hsv_pixel_s
{
	unsigned char hue;
	unsigned char sat;
	unsigned char val;
} hsv_pixel_t;


hsv_pixel_t ccvt_rgb24_hsv(unsigned char r, unsigned char g, unsigned char b);

void ccvt_420p_rgb24(int width, int height, const unsigned char *src, unsigned char *dst);

void ccvt_420p_grey8(int width, int height, const unsigned char *src, unsigned char *dst);

void ccvt_yuyv_rgb24(int width, int height, const unsigned char *src, unsigned char *dst);

void ccvt_yuyv_grey8(int width, int height, const unsigned char *src, unsigned char *dst);


#endif
